<?php 
	//中文编码
	header("Content-type:text/html;charset=utf-8");
	include_once("function.php") ;
	/**
	*   基础表 用于存储方法 
	*	链接数据库方法
	*	添加财务日志方法
	*	获取列表方法
	*/
	class base{
		//设置链接数据库参数
		private $db;
		private $host;
		private $user;
		private $pwd;
		private $name;
		private $charset;
		protected $config;
		function __construct(){
			echo 1;die;
			//获取数据库链接
			$this->host    = 'localhost';
			$this->user    = 'root';
			$this->pwd     = 'vicpassword.';
			$this->name    = 'zzqb';
			$this->charset = 'utf8';
			//获取配置项
			$this->config=$this->config();
			//不执行自动程序
			if($this->config['auto_switch']!=1){
				return;
			}
			
		}
		//系统参数的数组
		protected function config(){
			//$config = require_once('../App/Common/Conf/money_config.php');\
			$sql = "SELECT * FROM yang_config";
			$config = $this->select($sql);
			dump($config);
			foreach ($config as $k=>$v){
				$config_true[$v['key']] = $v['value'];
			}
			unset($config);
			return $config_true;
		}
		/***************************数据库链接部分*******************************************/
		//执行语句
		protected function query($sql){
			$link= mysql_connect($this->host,$this->user,$this->pwd) or die("数据库连接失败");
			mysql_select_db($this->name,$link);
			mysql_set_charset($this->charset);
			$result=mysql_query($sql,$link);
			mysql_close($link);
		}
		//返回一个结果集 只查一个的时候用
		protected function find($sql){
			$link= mysql_connect($this->host,$this->user,$this->pwd) or die("数据库连接失败");
			mysql_select_db($this->name,$link);
			mysql_set_charset($this->charset);
			$result=mysql_query($sql,$link);
			$user=mysql_fetch_assoc($result);
			mysql_free_result($result);
			mysql_close($link);
			return $user;
		}
		//返回一个结果集 查多个的时候用
		protected function select($sql){
			$res="";
			$link= mysql_connect($this->host,$this->user,$this->pwd) or die("数据库连接失败");
			mysql_select_db($this->name,$link);
			mysql_set_charset($this->charset);
			$result=mysql_query($sql,$link);
			while($user=mysql_fetch_assoc($result)){
				$res[]=$user;
			}
			mysql_free_result($result);
			mysql_close($link);
			return $res;
		}
		
	}
?>